package com.csst.task;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import com.csst.bean.Customer;
import com.csst.service.CustomerService;

@Component
public class AddCustomerTask {
	@Autowired
	private CustomerService service;
	@Scheduled(fixedDelay =3153600000L)
	public void say() {
		
			try {
				List<Customer> customers= service.list();
				if (customers.size()==0) {
					initialization();
				}
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	
	private void initialization() {
		Customer customer=new Customer();
		customer.setCustName("李春");
		customer.setAge(11);
		customer.setPwd("123456");
		customer.setAddress("江苏大丰");
		service.save(customer);
		
	}

}
